#include <sys/epoll.h>
#include "Socket.h"


namespace yazi{
namespace socket{

class EventPoller{
    friend class SocketHandler;
public:
    EventPoller(bool et);
    ~EventPoller();
    bool create(int maxconnections);
    bool add(int fd, void *ptr, uint32_t events);
    bool mod(int fd, void *ptr, uint32_t events);
    bool del(int fd, void *ptr, uint32_t events);
    int wait(int millseconds);

protected:
    bool ctrl(int fd, void *ptr, uint32_t events, int op);

private:
    bool m_et;
    int m_epfd;
    int m_maxconnections;
    struct epoll_event* m_events;
};


}}
